
#include "TUICmd.h"
#include "run_ui.h"

int TUI_setCHOn(char CHItem,char OnOff)
{
  char buff[20];
  sprintf(buff,"A%dssNZ %d\n",CHItem+3,OnOff);
  printf(buff);
  packet_append(DRTC_PORT, buff, strlen(buff)+1);
  return 1;
}
int TUI_setCH_Pressure(char CHItem,long val)
{
  char buff[30];
  sprintf(buff,"A%dssPI %d\n",CHItem+3,val);
  printf(buff);
  packet_append(DRTC_PORT, buff, strlen(buff)+1);
  return 1;
}
int TUI_setCH_config(char CHItem)
{
  char buff[200];
  StepInfo *Values = m_TUIStatus.CHs[CHItem].Value;
  sprintf(buff,"A%dssPR %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",CHItem+3,
    Values[0].value_set,Values[1].value_set,Values[2].value_set,Values[3].value_set,
    Values[4].value_set,Values[5].value_set,Values[6].value_set,Values[7].value_set,
    Values[8].value_set,Values[9].value_set,Values[10].value_set);
  printf(buff);
  packet_append(DRTC_PORT, buff, strlen(buff)+1);
  return 1;
}
int TUI_setRun(char RunStatus)
{
  char buff[30];
  if(RunStatus == TUI_RUN_START)
  {
    sprintf(buff,"GCssPR\n");
    printf(buff);
    packet_append(DRTC_PORT, buff, strlen(buff)+1);

  }
  else if(RunStatus == TUI_RUN_STOP)
  {
    StopRun(Abort);//in run_ctrl/run_state.c
  }
  return 1;
}
